package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.StringUtils;
import org.apache.commons.collections4.CollectionUtils;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.AVipRentRecords;
import com.ruoyi.system.service.IAVipRentRecordsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 求租会员Controller
 *
 * @author gf
 * @date 2024-11-26
 */
@RestController
@RequestMapping("/system/aVipRentRecords")
public class AVipRentRecordsController extends BaseController {
    @Autowired
    private IAVipRentRecordsService aVipRentRecordsService;

    /**
     * 查询求租会员列表
     */
    @GetMapping("/list")
    public TableDataInfo list(AVipRentRecords aVipRentRecords) {
        startPage();
        List<AVipRentRecords> list = aVipRentRecordsService.selectAVipRentRecordsList(aVipRentRecords);
        return getDataTable(list);
    }

    /**
     * 导出求租会员列表
     */
    @Log(title = "求租会员", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AVipRentRecords aVipRentRecords) {
        List<AVipRentRecords> list = aVipRentRecordsService.selectAVipRentRecordsList(aVipRentRecords);
        ExcelUtil<AVipRentRecords> util = new ExcelUtil<>(AVipRentRecords.class);
        util.exportExcel(response, list, "求租会员数据");
    }

    /**
     * 获取求租会员详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(aVipRentRecordsService.selectAVipRentRecordsById(id));
    }

    /**
     * 新增求租会员
     */
    @Log(title = "求租会员", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AVipRentRecords aVipRentRecords) {
        return toAjax(aVipRentRecordsService.insertAVipRentRecords(aVipRentRecords));
    }

    /**
     * 修改求租会员
     */
    @Log(title = "求租会员", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AVipRentRecords aVipRentRecords) {
        return toAjax(aVipRentRecordsService.updateAVipRentRecords(aVipRentRecords));
    }

    /**
     * 删除求租会员
     */
    @Log(title = "求租会员", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(aVipRentRecordsService.deleteAVipRentRecordsByIds(ids));
    }

    /**
     * 逻辑删除求租会员
     */
    @Log(title = "求租会员", businessType = BusinessType.DELETE)
    @DeleteMapping("/logicDel/{ids}")
    public AjaxResult logicDel(@PathVariable Long[] ids) {
        return toAjax(aVipRentRecordsService.deleteAVipRentRecordsByIds(ids));
    }

    @GetMapping("/recordList")
    public AjaxResult recordList() {
        return success(aVipRentRecordsService.selectAVipRentRecordsRecordsList());
    }
}
